home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Common Stuff.h
-
- Contains: This is a standard set of includes and macros that are defined for all of the RAVE
- projects, including error checking code and debugging features.
-
- Written by: Timothy Carroll
-
- Copyright: Copyright ©1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/15/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #ifndef _COMMONSTUFF_
- #define _COMMONSTUFF_
-
- #pragma once
-
- // RAVE needs enums always int to be turned on
- #ifdef __MWERKS__
-
- #if !__option (enumsalwaysint)
- #error "Enums must be always int for RAVE to work properly"
- #endif
- #endif
-
- /*********************************************************************************
- # ERROR HANDLING MACROS
- #
- # These macros can be used to implement nice error handling within a function.
- # Essentially, all errors jump to an error handler at the end of the function, which
- # should cleanup any leftovers and return the appropriate error result.
- #
- # Note that the error handlers take a message string. This should be a good
- # indication of the actual error, and it will appear when debugging is turned on.
- #
- # The qDebugging macro can be used to implement sanity checking code that is only
- # compiled into debug builds.
- #
-
- #if qDebugging
- // do additional sanity checking here.
- #endif
- #
- # This could be used to check the internal validity of an object before acting on it
- #
- *********************************************************************************/
- #ifndef qDebugging
- #define qDebugging 1
- #endif
-
- #if qDebugging
- #define SIGNAL_ERROR(msg) {DebugStr(msg); goto error;}
- #else
- #define SIGNAL_ERROR(msg) {goto error;}
- #endif
-
- #define FAIL_NIL(y,msg) if (y == NULL) SIGNAL_ERROR(msg)
- #define FAIL_OSERR(y,msg) if (y != noErr) SIGNAL_ERROR(msg)
- #define FAIL_FALSE(y,msg) if (!y) SIGNAL_ERROR(msg)
-
-
-
- #endif /* _COMMONSTUFF_ */
-
-
-
-